package com.xboss.tv.ui;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.xboss.tv.R;
import com.xboss.tv.bean.Contacts;
import com.xboss.tv.fragment.CaiJingDataFragment;
import com.xboss.tv.fragment.CarDataFragment;
import com.xboss.tv.fragment.ChildDataFragment;
import com.xboss.tv.fragment.FashionDataFragment;
import com.xboss.tv.fragment.GameDataFragment;
import com.xboss.tv.fragment.HouseDataFragment;
import com.xboss.tv.fragment.JiadianDataFragment;
import com.xboss.tv.fragment.JiajuDataFragment;
import com.xboss.tv.fragment.JiaoYuDataFragment;
import com.xboss.tv.fragment.KejiDataFragment;
import com.xboss.tv.fragment.MeishiDataFragment;
import com.xboss.tv.fragment.MovieDataFragment;
import com.xboss.tv.fragment.MusicDataFragment;
import com.xboss.tv.fragment.NewsDataFragment;
import com.xboss.tv.fragment.TiyuDataFragment;
import com.xboss.tv.fragment.TravelDataFragment;

/**
 * Created by Administrator on 2017\7\23 0023.
 */

public class ItemContentActivity extends AppCompatActivity {

    public FragmentTransaction transaction;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.layout_menu_item_content);

        Contacts.addActivity(ItemContentActivity.this);

        int position = getIntent().getIntExtra("position", -1);

        FragmentManager manager = getFragmentManager();

        transaction = manager.beginTransaction();

        initView(position);
    }

    private void initView(int position) {

        switch (position) {
            case 0://要问数据
                transaction.add(R.id.menu_frame_content, new NewsDataFragment(), "news");
                transaction.commit();

                break;
            case 1://财经数据(易源数据)

                transaction.add(R.id.menu_frame_content, new CaiJingDataFragment(), "caijing");
                transaction.commit();

                break;
            case 2://音乐数据
                transaction.add(R.id.menu_frame_content, new MusicDataFragment(), "music");
                transaction.commit();
                break;
            case 3://体育数据(天行)

                transaction.add(R.id.menu_frame_content, new TiyuDataFragment(), "tiyu");
                transaction.commit();

                break;
            case 4://科技数据(天行)

                transaction.add(R.id.menu_frame_content, new KejiDataFragment(), "keji");
                transaction.commit();

                break;
            case 5://影视数据(易源数据)

                transaction.add(R.id.menu_frame_content, new MovieDataFragment(), "movie");
                transaction.commit();

                break;
            case 6://汽车数据(易源数据)

                transaction.add(R.id.menu_frame_content, new CarDataFragment(), "car");
                transaction.commit();

                break;
            case 7://游戏数据(易源数据)

                transaction.add(R.id.menu_frame_content, new GameDataFragment(), "game");
                transaction.commit();
                break;
            case 8://教育数据(易源数据)

                transaction.add(R.id.menu_frame_content, new JiaoYuDataFragment(), "jiaoyu");
                transaction.commit();

                break;
            case 9://儿童数据(京东万象)

                transaction.add(R.id.menu_frame_content, new ChildDataFragment(), "child");
                transaction.commit();

                break;
            case 10://旅游数据(天行)

                transaction.add(R.id.menu_frame_content, new TravelDataFragment(), "travel");
                transaction.commit();
                break;
            case 11://时尚数据(阿里云)

                transaction.add(R.id.menu_frame_content, new FashionDataFragment(), "fashion");
                transaction.commit();

                break;
            case 12://美食数据

                transaction.add(R.id.menu_frame_content, new MeishiDataFragment(), "meishi");
                transaction.commit();
                break;
            case 13://家电数据

                transaction.add(R.id.menu_frame_content, new JiadianDataFragment(), "jiadian");
                transaction.commit();
                break;
            case 14://家居数据

                transaction.add(R.id.menu_frame_content, new JiajuDataFragment(), "jiaju");
                transaction.commit();
                break;
            case 15://房产数据(易源数据)

                transaction.add(R.id.menu_frame_content, new HouseDataFragment(), "house");
                transaction.commit();

                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Contacts.isLoad = false;
    }
}
